trigger DeleteSRBRecord on Sub_Region_Budget__c(before delete) {
    Profile p  = [select id from profile where name=: 'System Administrator' or name =: '系统管理员'];
    if(system.trigger.isdelete){
        List<ID> Ids = new List<ID>();
        if(system.trigger.isdelete){
             for (Sub_Region_Budget__c srb: Trigger.old)
             {
                 if((srb.ApprovalStatusFormula__c != null)&&(p.id != UserInfo.getProfileId()))
                 {
                     srb.addError('该记录不能被删除!');
                 }
                 else
                 {
                     Ids.add(srb.id);
                 }
                 
             }
             List<CityBudget__c> CBList = [Select id From CityBudget__c Where SubRegionBudget__c in:Ids];
             Delete CBList;
        }
    }
}